﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>短信管理</title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/JqueryPlug/zTree_v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <link href="/CSS/V3/animate.css" rel="stylesheet"> 
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.css?v=4.3.0" rel="stylesheet">
    <link href="/CSS/V3/style.css?v=2.2.0" rel="stylesheet">
    <link href="/CSS/V3/BaseClassV3.css" rel="stylesheet" />
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script src="/JqueryPlug/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
    <script src="/JqueryPlug/zTree_v3/js/jquery.ztree.excheck-3.5.min.js"></script>
    <script>
        var zNodes = null;
        var zTreeObj = null;
        var model = avalon.define({
            $id: "APP_DXGL",
            currStatus: "",
            queryuser: ComFunJS.getnowuser(),
            username: ComFunJS.getnowuser(),
            menutype:"-1",
            fnqueryuser: function (item) {
                if (item) {
                    model.queryuser = item; //item.UserName;
                    model.CommonData.clear();
                    model.GetDataList();
                }

            } ,
            SearchContent: "",
            CommonData: [],
            GetDataList: function (status) { 
                if (status!=null) {
                    model.currStatus = status;
                }
                $.getJSON('/API/FTAPI.ashx?Action=GETDXGLLIST_PAGE', { P1: model.SearchContent, p: 1, QUSER:  model.queryuser,b:model.menutype, P2: model.currStatus }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.CommonData = resultData.Result;
                        laypage({
                            cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                            pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / 8), //通过后台拿到的总页数
                            curr: 1, //初始化当前页
                            jump: function (e) { //触发分页后的回调 
                                $.getJSON('/API/FTAPI.ashx?Action=GETDXGLLIST_PAGE', { P1: model.SearchContent, p: e.curr, QUSER: model.queryuser, b: model.menutype, P2: model.currStatus }, function (resultData) {
                                    model.CommonData = resultData.Result; 
                                })
                            }
                        });
                    }
                })

            },
            addDXGL: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=DXGL", "短信管理", "1000", "");
            },
            DelDX:function(item) {
            parent.ComFunJS.winconfirm("确认要删除么", function () {
                $.post("/API/FTAPI.ashx", { Action: "DELDXGL", P1: item.ID }, function (result) {
                    var jsonresult = $.parseJSON(result)
                    if ($.trim(jsonresult.ErrorMsg) != "") {
                        parent.ComFunJS.winwarning(jsonresult.ErrorMsg);
                    } else {
                        model.CommonData.remove(item);
                        parent.ComFunJS.winsuccess("删除成功");
                    }
                })
            }, function () { })
            },
            IsShowTR: false,
            getMenu: function () {
                var setting = {
                    data: {
                        simpleData: {
                            enable: true,
                            idKey: "id",
                            pIdKey: "pId",
                            rootPId: 0
                        }
                    },
                    view: {
                        showLine: false
                    },
                    callback: {
                        onClick: model.zTreeOnClick
                    }
                };
                $.ajax({
                    type: "GET",
                    url: "/API/SZHLAPI.ashx",
                    dataType: "html",
                    data: { "Action": "GETALLBMUSERLIST" },
                    success: function (msg) {
                        if (JSON.parse(msg).Result) {
                            model.IsShowTR = true;
                        }
                        zTreeObj = $.fn.zTree.init($("#tree"), setting, eval(JSON.parse(msg).Result));
                    }
                });
            },
            zTreeOnClick: function (event, treeId, treeNode) {
                model.queryuser = "";
                model.CommonData.clear();
                if (treeNode.isUser) {
                    model.queryuser = treeNode.id;
                } else {
                    model.menutype = treeNode.id;
                    if (treeNode.children.length > 0 && treeNode.children[0].isUser) {

                        $(treeNode.children).each(function (i, user) {
                            model.queryuser += user.id + ",";
                        })
                        model.queryuser = model.queryuser.substring(0, model.queryuser.length - 1);
                    }
                }
                model.GetDataList(model.currStatus);
            }
        }); 

        avalon.ready(function () {
            ComFunJS.initsetajax();
            ComFunJS.initForm();
            model.getMenu();
            model.GetDataList('');
        })
        $(function () { 
            $("input[type=checkbox]").click(function () {
                $(".szhl_form_date_time").toggle();
                if (!$("input[type=checkbox]").prop("checked")) {
                    model.modelData.SendTime = "";
                    $("button[type=button]").text("立即发送")
                } else {
                    $("button[type=button]").text("定时发送")
                }
            })
        })
    </script>


</head>
<body ms-controller="APP_DXGL" class="gray-bg">

    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-content" style="border: 0; border-right: 1px solid #e7eaec;">
                        <div class="file-manager">
                            <div class="hr-line-dashed"></div>
                            <button class="btn btn-primary btn-block" ms-click="addDXGL()">添加短信</button>
                            <div class="hr-line-dashed"></div>
                            <h4>类型</h4>
                            <button class="btn  btn-sm" ms-class-1="btn-primary:model.currStatus==''" ms-class-2="btn-white:model.currStatus!=''" ms-click="GetDataList('')" type="button">全部</button>
                            <button class="btn  btn-sm  " ms-class-1="btn-primary:model.currStatus=='Y'" ms-class-2="btn-white:model.currStatus!='Y'" ms-click="GetDataList('Y')" style="margin-right:5px" type="button">已发短信</button>
                            <button class="btn  btn-sm " ms-class-1="btn-primary:model.currStatus=='N'" ms-class-2="btn-white:model.currStatus!='N'" ms-click="GetDataList('N')" style="margin-right:5px" type="button">未发短信</button>
                            <div class="hr-line-dashed"></div>
                            <h4 class="tag-title" ><a href="APP_DXGL.html">我的短信</a></h4>
                            <div class="clearfix"></div>
                            <h4 class="tag-title" ms-if="model.IsShowTR">他人短信</h4>
                            <ul id="tree" ms-if="model.IsShowTR" class="ztree"></ul>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-9">
                <div class="ibox">
                    <div class="box" style="margin-bottom:15px;">

                        <div class="pull-right mail-search">
                            <div class="input-group">
                                <input type="text" class="form-control input-sm" ms-duplex="SearchContent" name="search" placeholder="搜索短信内容">
                                <div class="input-group-btn">
                                    <button type="submit" class="btn btn-sm btn-primary" ms-click="GetDataList(model.currStatus)">
                                        搜索
                                    </button>
                                </div>
                            </div>
                        </div>
                        <h2>
                            短信管理
                        </h2>
                        <div class="mail-tools tooltip-demo m-t-md">
                            <div class="btn-group pull-right">
                                <div id="pageDiv" class="text-center"></div>
                            </div>
                            <div class="clearfix"></div>
                        </div>

                    </div>

                </div>
                <div class="full-height-scroll">
                    <div class="table-responsive">
                        <table class="table  table-hover" style="table-layout: fixed">
                            <thead>
                                <tr>
                                    <th style="width:50px">序号</th>
                                    <th>短信内容</th>
                                    <th style="width:200px">接收号码</th> 
                                    <th style="width:100px">发送状态</th>
                                    <th style="width:100px">发送日期</th>
                                    <th style="width:100px">添加日期</th>
                                    <th style="width:100px">发送人</th>
                                    <th style="width:100px">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ms-repeat-el="CommonData">
                                    <td>
                                        {{$index+1}}
                                        <a data-toggle="tab" href="#contact-1" class="client-link">{{el.KHName}}</a>
                                    </td>
                                    <td>
                                        {{el.dxContent}}
                                    </td>
                                    <td ><span style="width:200px;overflow: hidden; word-wrap: break-word;" >{{ComFunJS.convstr(el.dxnums,59)}}</span></td>
                                    <td>{{el.isSend=='Y'?'已发送':'未发送'}}</td>
                                    <td> {{el.SendTime}}</td>

                                    <td> {{el.CRDate}}</td>
                                    <td> {{ComFunJS.convertuser(el.CRUser)}}</td>

                                    <td class="client-status">
                                        <button class="btn btn-xs btn-danger" style="margin-left:10px;" ms-click="DelDX(el)" ms-if="el.CRUser==username"><i class="fa fa-trash-o"></i>  删除</button>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
</body>
</html>
